<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body>
<script>
var layoutTest = async_test('Finish event should be delivered even if a GC occurs. This test passes if it does not time out.');
var events = 0;

function finish() {
  if (window.GCController)
    GCController.collect();
  if (++events == 2)
    layoutTest.done();
}

// Use a distinct, unreferenced instance of the handler function.
document.body.animate([]).onfinish = finish.bind();
document.body.animate([]).onfinish = finish.bind();

if (window.GCController)
  GCController.collect();
</script>
